package cn.smbms.service.bill;

import cn.smbms.dao.bill.BillMapper;
import cn.smbms.pojo.Bill;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BillServiceImpl implements BillService {
    @Resource
    private BillMapper billMapper;

    @Override
    public boolean add(Bill bill) {
        boolean flag = false;
        try {
            if (billMapper.add(bill) > 0)
                flag = true;
        } catch (Exception e) {

            e.printStackTrace();
            System.out.println("rollback==================");
        }
        return flag;
    }

    @Override
    public List<Bill> getBillList(Bill bill) {

        List<Bill> billList = null;
        try {
            billList = billMapper.getBillList(bill);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return billList;
    }

    @Override
    public boolean deleteBillById(String delId) {

        boolean flag = false;
        try {
            if (billMapper.deleteBillById(delId) > 0)
                flag = true;
        } catch (Exception e) {

            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public Bill getBillById(String id) {
        Bill bill = null;
        try {
            bill = billMapper.getBillById(id);
        } catch (Exception e) {
            e.printStackTrace();
            bill = null;
        } finally {

        }
        return bill;
    }

    @Override
    public boolean modify(Bill bill) {
        boolean flag = false;
        try {
            if (billMapper.modify(bill) > 0)
                flag = true;
        } catch (Exception e) {

            e.printStackTrace();
        } finally {

        }
        return flag;
    }

}
